package Demo2;

public class Derived extends Base{
    public int a = 10;
    public int c = 3;

    public void testDerived(){
        System.out.println("子类的testDerived方法");
    }

    public void testBase(){
        System.out.println("子类的testBase方法");
    }
    public void method2(){
        testDerived();
        testBase();        //方法名相同时优先调用子类的testBase()方法
    }

    public void method(){
        /*this.a = 10;
        this.b = 20;
        this.c = 30;
*/
        System.out.println("父类的a值为:" + super.a); //super关键字：表示访问父类的值
        System.out.println(this.a);                 //子类和父类同时有a,优先访问子类的a
        System.out.println(this.b);                 //子类无b，则去父类中访问
        System.out.println(this.c);
    }
}
